Dates in ASP

Results 1 to 3 of 3

Thread: Dates in ASP

  1. #1
    Join Date
    Dec 1969

    Default Dates in ASP

    I&#039m having problems formatting dates. The Database on the NT Server is updating using UK-style dates. The browser and server Date Function is displaying and using US-style dates. It&#039s nigh on impossible to compare two dates, eg. a date in the DB and Date. Is there any code out there to format the dates in UK or US style, or simply switching month and day around. I would do it myself but if there&#039s code already existing, that would be better!! Cheers, Guy.

  2. #2
    BalletChick Guest

    Default RE: Dates in ASP

    Are you using SQL Server?<BR><BR>If so, look in the BooksOnLine (help) under Set Dateformat. Here is an excerpt:<BR><BR>SET DATEFORMAT<BR>Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data.<BR>Syntax<BR>SET DATEFORMAT { format &#124 @format_var }<BR>Arguments<BR>format &#124 @format_var<BR>Is the order of the dateparts. Can be either Unicode or DBCS converted to Unicode. Valid parameters include mdy, dmy, ymd, ydm, myd, and dym. The U.S. English default is mdy.<BR>Remarks<BR>This setting is used only in the interpretation of character strings as they are converted to date values. It has no effect on the display of date values.<BR>The setting of SET DATEFORMAT is set at execute or run time and not at parse time.<BR>Permissions<BR>SET DATEFORMAT permissions default to all users.<BR>Examples<BR>This example uses different date formats to handle date strings in different formats.<BR>SET DATEFORMAT mdy<BR>GO<BR>DECLARE @datevar datetime<BR>SET @datevar = &#039 12/31/98&#039<BR>SELECT @datevar<BR>GO<BR> <BR>SET DATEFORMAT ydm<BR>GO<BR>DECLARE @datevar datetime<BR>SET @datevar = &#039 98/31/12&#039<BR>SELECT @datevar<BR>GO<BR> <BR>SET DATEFORMAT ymd<BR>GO<BR>DECLARE @datevar datetime<BR>SET @datevar = &#039 98/12/31&#039<BR>SELECT @datevar<BR>GO<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Please read...

    This post may help:<BR><BR>It&#039s one of my favourites, and it removes any need to worry about date formats.<BR><BR>Dunc

Posting Permissions

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