Re: Date Variable
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Sep 2005 12:07:39 +0100
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.
>
>
.
- References:
- Date Variable
- From: Joel
- Re: Date Variable
- From: Rick Rothstein [MVP - Visual Basic]
- Re: Date Variable
- From: ProfitMaxTrading.com
- Re: Date Variable
- From: Ivar
- Re: Date Variable
- From: Dag Sunde
- Date Variable
- Prev by Date: Re: Date Variable
- Next by Date: Re: Computing for Outlook Express in VB.
- Previous by thread: Re: Date Variable
- Next by thread: Re: Date Variable
- Index(es):
Relevant Pages
|