Solved

Convert sysdate to varchar(10)

Posted on 2008-10-24
4
1,092 Views
Last Modified: 2013-11-16
I need to convert sysdate to a varchar(10) field and just include the date not the time in that field, what would be the proper casting or syntax for this?
0
Comment
Question by:wyogirl77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:jamesgu
ID: 22797847
SELECT CONVERT(VARCHAR(10), GETDATE() , 102)
SELECT CONVERT(VARCHAR(10), GETDATE() , 121)
...

check this

http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx
0
 

Author Comment

by:wyogirl77
ID: 22798583
Would this work then, I am not sure about the else clause basically what I wanted to do was if the OutOfOfficeUntilDate is null I want to insert the system date into that field otherwise just continue on?

CREATE TRIGGER trg_Asgnmnt_OutOfOffice ON dbo.Asgnmnt
FOR UPDATE
AS
      IF UPDATE(OutOfOffice) BEGIN
            UPDATE      dbo.Assignee
               SET      OutOfOffice = I.OutOfOffice,
                  OutOfOfficeUntilTime = I.OutOfOfficeUntilTime,
                  OutOfOfficeUntilDate = I.OutOfOfficeUntilDate
                  if OutOfOfficeUntilDate is Null then SET OutOfOfficeUntilDate = CONVERT(Varchar(10), GETDATE(), 101) ELSE OutOfOfficeUntilDate = OutOfOfficeUntilDate
            FROM      dbo.Assignee A,
                  INSERTED I
            WHERE      A.LoginID = I.LoginID
              AND      I.CallID = '00010000'
      END
GO
0
 
LVL 9

Accepted Solution

by:
jamesgu earned 125 total points
ID: 22798750
            if OutOfOfficeUntilDate is Null then SET OutOfOfficeUntilDate = CONVERT(Varchar(10), GETDATE(), 101) ELSE OutOfOfficeUntilDate = OutOfOfficeUntilDate


change this to

SET OutOfOfficeUntilDate = isnull( CONVERT(Varchar(10), GETDATE(), 101) , OutOfOfficeUntilDate )
0
 

Author Closing Comment

by:wyogirl77
ID: 31509720
Great Thank you so much!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question