Make a date European Standard

Results 1 to 5 of 5

Thread: Make a date European Standard

  1. #1
    Tired as hell Guest

    Default Make a date European Standard

    I was given code from a previous project and was asked to, among about 500 other changes, to change the date from mm/dd/yy to the standard for Europe which is dd/mm/yy.<BR>The code also checks to see if the date is at least three weeks in the future and prompts if it is not.<BR>Here is the code i was given:<BR><BR>Sub checkDate(field)<BR>On Error Resume Next<BR>If field.value&#060;&#062;"" then<BR>If IsDate(field.value)=false then<BR>alert("Please enter the date in the form mm/dd/yy.")<BR> field.focus<BR> field.value=""<BR> Else <BR> field.value=FormatDateTime(field.value,2)<BR> If = "DueDate" then<BR> If DateDiff("D",now,field.value) &#060; 1 then<BR> alert("Please enter later date.")<BR> field.focus<BR> field.value=""<BR> Elseif DateDiff("D",now,field.value) &#060; 21 then<BR> Call show(ExplainDate)<BR> ReqEur.ExplainDate.focus<BR> alert("Requests made for less than three weeks need justification to be approved.")<BR> ExplainDate.focus<BR> Else<BR> Call hide(ExplainDate)<BR> End if<BR> End if<BR> End if<BR> Elseif = "DueDate" and field.value = "" then<BR> Call hide(ExplainDate) <BR> End if<BR>End sub<BR><BR>Thanks,<BR>T.A.H.

  2. #2
    Join Date
    Dec 1969

    Default Use LCID for fun and profit...

    &#060;%<BR>SaveLCID = Session.LCID<BR>Session.LCID = &h0c09 &#039; or other appropriate European Locale!<BR>strDate = FormatDateTime( whatever, vbLongDate ) &#039; or vbShortDate<BR>...<BR>Session.LCID = SaveLCID<BR>%&#062;<BR><BR>If you use vbLongDate, then you will get the month name (and, for some countries, the weekday name) spelled out in the language of the country specified by the LCID. So maybe vbShortDate is safer.<BR><BR>Of course, you could also construct the thing by hand:<BR><BR>&#060;%<BR>strDate = Day(someDate) & "-" & Month(someDate) & "-" & Year(someDate)<BR>%&#062;<BR><BR>If you use LCID, though, then converting a string to a date (e.g., using CDATE or any of the date functions) will automatically assume the format specified as default for that LCID. So even input from the form will be accepted correctly without your doing any extra work.<BR><BR>Note that once a date is in a variable *as* a date, then all the other date functions (e.g., DateAdd, DateDiff) work properly. The internal format of a date is QUITE different than the string/text format.<BR><BR>

  3. #3
    Tired As Hell Guest

    Default RE: Use LCID for fun and profit...

    Forgive my novice ways, but where would that go in my code?<BR><BR>Thanks for the help!

  4. #4
    Join Date
    Dec 1969

    Default If you want ALL the code... use European dates, you can just put Session.LCID = xxxx at the top of the page. That SaveLCID is just to remember the current setting and restore it when you are done.<BR><BR>Basically, you surround any code that you want to use European dates with the setting and restoring of the LCID. And that can be the entire page. Or even the entire user Session! Since Session.LCID is remembered from page to page.<BR><BR>Check the MS docs for valid values of LCID, incidentally.<BR><BR>

  5. #5
    Tired As Hell Guest

    Default RE: If you want ALL the code...

    Thanks man!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts