Re: Date Variable



The point Ivar was trying to make is that using String values to represent
Dates is fundamentally wrong. Sure, using ISO date strings avoids locale
issues, but it doesn't help you much if you need to do any sort of date
arithmetic. The Date data type is provided for efficiency as much as
unambiguity.

Tony Proctor

"Dag Sunde" <me@xxxxxxxxxxxx> wrote in message
news:AA8_e.6182$qE.1283098@xxxxxxxxxxxxxxxxxx
> "Ivar" <ivar.ekstromer000@xxxxxxxxxxxx> wrote in message
> news:lz7_e.518$OC3.357@xxxxxxxxxxxxxxxxxxxxxxx
> >
> >> On the subject of a 'Date' variable, what purposes does it serve?
> >
> >> I've been using STRING variables to handle dates in all my apps. Never
> >> gave the Date variable much thought.
> >>
> >> ??
> >
> > Try running the code snippet below. It will show you the error of your
> > ways :-)
> >
> > Dim sDate1 As String
> > Dim sDate2 As String
> > Dim DDate1 As Date
> > Dim DDate2 As Date
> > sDate1 = "31/Jan/2005"
> > sDate2 = "01/Feb/2005"
> > DDate1 = sDate1
> > DDate2 = sDate2
> > If sDate1 > sDate2 Then
> > MsgBox sDate1 & " is After " & sDate2
> > End If
> > If DDate1 < DDate2 Then
> > MsgBox sDate1 & " is before " & sDate2
> > End If
>
> No it wont... Because your code is flawed!
>
> ;-)
>
> One should *never* use country-specific date-formats in code!
> *Always* use ISO date formats, and feel the force... :-)
>
> Change the two following lines to the date-format of the righteous:
> sDate1 = "2005-01-31"
> sDate2 = "2005-02-01"
>
> and run your code once again...
>
> ISO-8601:
> * 100% unabigiuos
> * Human readable
> * Machine readable
> * Sortable
> * In compact form (yyyymmdd without the hypens) calculateable
> * Internationally understandable
>
> LOL
>
> --
> Dag.
>
>


.



Relevant Pages

  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Help answer these 70-310 questions
    ... One argument is the string ... Dim output As New StringBuilder ... EmployeeLocations. ... You create a strongly named serviced component. ...
    (microsoft.public.cert.exam.mcsd)