# Shape file date column retrieving the data

**URL:** <https://community.thinkgeo.com/t/shape-file-date-column-retrieving-the-data/5365>\
**Category:** WebForms\
**Created:** [June 22, 2010, 12:04pm UTC](https://community.thinkgeo.com/t/shape-file-date-column-retrieving-the-data/5365 "2010-06-22T12:04:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rui](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Rui](https://community.thinkgeo.com/u/Rui)\
**Post date:** [June 22, 2010, 12:04pm UTC](https://community.thinkgeo.com/t/shape-file-date-column-retrieving-the-data/5365/1 "2010-06-22T12:04:29Z")

</div>

Could&nbsp;you&nbsp;please&nbsp;take&nbsp;a&nbsp;look&nbsp;at&nbsp;the&nbsp;attached&nbsp;example.  
  
I&nbsp;have&nbsp;a&nbsp;shape&nbsp;file&nbsp;in&nbsp;wich&nbsp;i&nbsp;have&nbsp;a&nbsp;date&nbsp;column.  
  
But&nbsp;thinkgeo&nbsp;shapefeaturesource&nbsp;in&nbsp;columnvalues&nbsp;is&nbsp;not&nbsp;giving&nbsp;me&nbsp;a&nbsp;valid&nbsp;date&nbsp;format.  
  
Can&nbsp;you&nbsp;help&nbsp;me&nbsp;with&nbsp;this?  
  
  
  
In&nbsp;the&nbsp;test&nbsp;page&nbsp;i&nbsp;have&nbsp;two&nbsp;buttons,&nbsp;a&nbsp;gridview,&nbsp;a&nbsp;label&nbsp;and&nbsp;a&nbsp;calendar&nbsp;control.

when&nbsp;i&nbsp;press&nbsp;the&nbsp;first&nbsp;button&nbsp;the&nbsp;gridview&nbsp;is&nbsp;filled&nbsp;with&nbsp;all&nbsp;(untyped)&nbsp;data.

When&nbsp;i&nbsp;press&nbsp;the&nbsp;second&nbsp;button,&nbsp;i&nbsp;put&nbsp;the&nbsp;value&nbsp;from&nbsp;the&nbsp;date&nbsp;field&nbsp;(as&nbsp;string)&nbsp;into&nbsp;the&nbsp;a&nbsp;label&nbsp;value.&nbsp;  
  
And&nbsp;i&nbsp;would&nbsp;like&nbsp;to&nbsp;select&nbsp;the&nbsp;date&nbsp;in&nbsp;the&nbsp;calendar,&nbsp;but&nbsp;is&nbsp;gives&nbsp;me&nbsp;the&nbsp;exception:  
  
System.InvalidCastException:&nbsp;Conversion&nbsp;from&nbsp;string&nbsp;"20080924"&nbsp;to&nbsp;type&nbsp;'Date'&nbsp;is&nbsp;not&nbsp;valid.&nbsp;at&nbsp;Microsoft.VisualBasic.CompilerServices.Conversions.ToDate(String&nbsp;Value)&nbsp;at&nbsp;  
  
  
  
&nbsp;

[sThinkGeo\_SHPDateProblem.zip](https://community.thinkgeo.com/uploads/default/original/1X/078ef12538266d82b80489f517c20f203888a34b.zip) (48 KB)

---

<div class="post-metadata">

**Author:** ![Khalil](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/bc8723/32.png) [@Khalil](https://community.thinkgeo.com/u/Khalil)\
**Post date:** [June 23, 2010, 8:29pm UTC](https://community.thinkgeo.com/t/shape-file-date-column-retrieving-the-data/5365/2 "2010-06-23T20:29:16Z")

</div>

Hi,&nbsp;Rui  
  
  
  
I&nbsp;think&nbsp;the&nbsp;problem&nbsp;is&nbsp;caused&nbsp;by&nbsp;that&nbsp;you&nbsp;want&nbsp;to&nbsp;convert&nbsp;the&nbsp;date&nbsp;string&nbsp;to&nbsp;Date&nbsp;object&nbsp;and&nbsp;so&nbsp;the&nbsp;exception&nbsp;throws.  
  
I&nbsp;suggest&nbsp;that&nbsp;when&nbsp;you&nbsp;have&nbsp;got&nbsp;the&nbsp;string&nbsp;from&nbsp;the&nbsp;date&nbsp;filed&nbsp;of&nbsp;Shape&nbsp;File&nbsp;and&nbsp;parse&nbsp;it&nbsp;manually.&nbsp;Please&nbsp;refer&nbsp;to&nbsp;the&nbsp;code&nbsp;below:

`                lblDateValue.Text = features.First().ColumnValues.Item("DELIB_ELAB")                Dim year As Integer = lblDateValue.Text.Substring(0, 4)                Dim month As Integer = lblDateValue.Text.Substring(4, 2)                Dim day As Integer = lblDateValue.Text.Substring(6, 2)                Dim dt As DateTime = New DateTime(year, month, day)                cal.TodaysDate = dt`

Also&nbsp;if&nbsp;the&nbsp;date&nbsp;format&nbsp;is&nbsp;different&nbsp;from&nbsp;yyyymmdd&nbsp;and&nbsp;you&nbsp;need&nbsp;to&nbsp;change&nbsp;the&nbsp;code.

Thanks,

Khalil

---

<div class="post-metadata">

**Author:** ![Rui](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@Rui](https://community.thinkgeo.com/u/Rui)\
**Post date:** [June 24, 2010, 3:47am UTC](https://community.thinkgeo.com/t/shape-file-date-column-retrieving-the-data/5365/3 "2010-06-24T03:47:08Z")

</div>

Khalil,&nbsp;thanks.&nbsp;  
&nbsp;After&nbsp;some&nbsp;research&nbsp;found&nbsp;out&nbsp;that&nbsp;in&nbsp;dbf&nbsp;the&nbsp;Date&nbsp;field&nbsp;are&nbsp;allways&nbsp;stored&nbsp;as&nbsp;8byte,&nbsp;allways&nbsp;as&nbsp;YYYYMMDD,&nbsp;so&nbsp;like&nbsp;you’ve&nbsp;said&nbsp;i’ve&nbsp;to&nbsp;parse&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;was&nbsp;hoping&nbsp;that&nbsp;in&nbsp;you&nbsp;ColumnValues&nbsp;you&nbsp;returned&nbsp;the&nbsp;Date&nbsp;as&nbsp;“YYYY/MM/DD”,&nbsp;so&nbsp;i&nbsp;could&nbsp;use&nbsp;it&nbsp;directly&nbsp;without&nbsp;having&nbsp;to&nbsp;verify&nbsp;if&nbsp;is&nbsp;or&nbsp;not&nbsp;a&nbsp;shp&nbsp;layer.&nbsp;  
&nbsp;&nbsp;  
&nbsp;But&nbsp;no&nbsp;problem,&nbsp;it’s&nbsp;fixed.&nbsp;:)

---

<div class="post-metadata">

**Author:** ![Khalil](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/bc8723/32.png) [@Khalil](https://community.thinkgeo.com/u/Khalil)\
**Post date:** [June 24, 2010, 7:32pm UTC](https://community.thinkgeo.com/t/shape-file-date-column-retrieving-the-data/5365/4 "2010-06-24T19:32:59Z")

</div>

Rui,&nbsp;  
&nbsp;&nbsp;  
&nbsp;You’re&nbsp;welcome.&nbsp;OK,&nbsp;we&nbsp;will&nbsp;consider&nbsp;your&nbsp;suggestion&nbsp;about&nbsp;it.&nbsp;If&nbsp;you&nbsp;still&nbsp;have&nbsp;any&nbsp;problems&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Khalil
