?
Solved

Convert sysdate to varchar(10)

Posted on 2008-10-24
4
Medium Priority
?
1,099 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 500 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 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