Automated fields ?

  • Hi all,

              I have got a form on a webpage that allows the users to input data to a SQL Server table and I would like to be able to write to two fields on the 'afterupdate' of another field. The two fields being time/date stamps. In Access this is a easy task, just use =Now() function but do I go about this using DWMX or should this be done using SQL Server ? If so how do I do this, do I have to write a trigger or something ? 

    Regards,

    Mitch.

  • Have you tried SQL Server's GetDate() function?

     


    Butch

  • Thanks Butch,

                      that worked great but how do I go about formatting the

    value to a specific look, for example instead of the whole value showing date and time i'd like just the date for this one field and the time in another field. In Access you can change how it looks like 1:24 or 13:24pm ?

    I tried using help looking up functions but it was'nt very helpfull !

    Mitch....

  • Mitch,

    Check BOL for "Cast and Convert"

    Here's some examples of JUST date or JUST time or both:

    select  CONVERT (varchar(20),GetDate(),100) --Gets default date/time

    select  CONVERT (varchar(12),GetDate(),101) --Gets JUST the date

    select  CONVERT (varchar(12),GetDate(),102)

    select  CONVERT (varchar(12),GetDate(),103)

    select  CONVERT (varchar(12),GetDate(),104)

    select  CONVERT (varchar(12),GetDate(),105)

    select  CONVERT (varchar(12),GetDate(),106)

    select  CONVERT (varchar(12),GetDate(),107)

    select  CONVERT (varchar(12),GetDate(),108)

    select  CONVERT (varchar( 5),GetDate(),108) --Gets JUST the time

    select  Right(CONVERT (varchar(20),GetDate(),100),7) --Gets JUST the time in AM/PM format

    You won't need separate fields for one timestamp.  Change the GETDATE() to your field name and you should be good to go for display purposes.


    Butch

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply