Re:Date Problem

From: Vishal Parkar (vgparkar@hotmail.com)
Date: 03/08/03

  • Next message: David Pendleton: "Re: Package will not authenticate"
    From: "Vishal Parkar" <vgparkar@hotmail.com>
    Date: Sat, 8 Mar 2003 03:52:05 -0800
    
    

    You can SET DATEFORMAT and modify code as follows.

    create table test(dt datetime)
    go
    declare @dt varchar(32)
    set @dt ='26/07/2002'
    set dateformat dmy --change dateformat
    insert into test values(convert(datetime,@dt)) ;
    select * from test;
    go

    OR other method would be to use explicit coversion of the
    date using CONVERT function.

    create table test(dt datetime)
    go
    declare @dt varchar(32)
    set @dt ='26/07/2002'
    insert into test values(convert(datetime,@dt, 103)) ;
    select * from test;
    go

    --Vishal

    >-----Original Message-----
    >Hi
    >
    >I've got a problem with date formatting. I'm accessing a
    sqlServer 2000
    >database using asp.net. When the dates are entered into
    the database they
    >appear in the format that I want them (dd/mm/yyyy). When
    they are called
    >from the database and displayed in the web page they are
    also in this
    >format. However when I come to update the date an
    exception occurs. The
    >data will only be updated if it is converted to the
    mm/dd/yyyy format.
    >
    >Any Ideas?
    >
    >Cheers
    >
    >Daniel
    >
    >
    >.
    >


  • Next message: David Pendleton: "Re: Package will not authenticate"

    Relevant Pages

    • Re: Date Problems - ASP/SQL
      ... a DATETIME column does NOT store DD/MM/YYYY format. ... DECLARE @dt SMALLDATETIME ... data> type to a datetime data type resulted in an out-of-range datetime value. ...
      (microsoft.public.inetserver.asp.general)
    • Re: convert a date to a string?
      ... converting it to a CHARACTER string. ... Also, don't convert it back to a datetime, or put it in a datetime variable, ... or you'll lose the format. ... >>> Declare @m int ...
      (microsoft.public.sqlserver.programming)
    • Re: DATE Format
      ... i Have a database in SQLserver. ... I am using php to connect to it and to retrieve data from that ... where can i change de that default format? ... I doubt if the column is DATATIME, it is more likely DATETIME. ...
      (comp.lang.php)
    • RE: Select across databases
      ... > How would I add this to the query? ... > also in the other database. ... > DECLARE @startdate AS DATETIME ...
      (microsoft.public.sqlserver.programming)
    • RE: DateTime Parse and CultureInfo problem.
      ... any parsing when reading them from the database. ... The DateTime.ParseExact can only parse a string if the format is exactly as ... > String was not recognized as a valid DateTime. ...
      (microsoft.public.dotnet.framework)