I need date without Time

I need date without Time

Post by Adam |losarsk » Thu, 12 Jun 2003 20:37:13



how to get only DATE without Time?

i use query   select mydate from table

field mydate is DATETIME type and contains i.e 2002-01-01 13:45:34

i need to get only 2002-01-01 - what i have to do?

function DATEPART only gets the one part, i need to get YEARTODAY.
function CONVERT only uses predefined styles, why??? why i can't use like
this  select FORMATDATE('yyyy-mm-dd', mydate) from ....   ???

--
Adams

 
 
 

I need date without Time

Post by Jaan » Thu, 12 Jun 2003 20:40:18


You can try   select convert(char(10),getdate(),120)



Quote:> how to get only DATE without Time?

> i use query   select mydate from table

> field mydate is DATETIME type and contains i.e 2002-01-01 13:45:34

> i need to get only 2002-01-01 - what i have to do?

> function DATEPART only gets the one part, i need to get YEARTODAY.
> function CONVERT only uses predefined styles, why??? why i can't use like
> this  select FORMATDATE('yyyy-mm-dd', mydate) from ....   ???

> --
> Adams


 
 
 

I need date without Time

Post by Tibor Karasz » Thu, 12 Jun 2003 21:05:49


Which returns a string, not datetime data. Returning datetime data without a time component is
impossible. Either return a string, or set the time portion to 00:00

select CAST(convert(char(10),getdate(),112) AS datetime)

--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sql...


> You can try   select convert(char(10),getdate(),120)



> > how to get only DATE without Time?

> > i use query   select mydate from table

> > field mydate is DATETIME type and contains i.e 2002-01-01 13:45:34

> > i need to get only 2002-01-01 - what i have to do?

> > function DATEPART only gets the one part, i need to get YEARTODAY.
> > function CONVERT only uses predefined styles, why??? why i can't use like
> > this  select FORMATDATE('yyyy-mm-dd', mydate) from ....   ???

> > --
> > Adams

 
 
 

I need date without Time

Post by Adam ?losarsk » Thu, 12 Jun 2003 21:17:33



Quote:> You can try   select convert(char(10),getdate(),120)

ok, but this could be not compatible, if MS will change behavior in future
releases of sql server

MS should add more function to operate on data types, because now it's wrong
to make low level operations like char(10) substrings

thanks Jaana

Quote:> Adams

 
 
 

I need date without Time

Post by Quentin Ra » Fri, 13 Jun 2003 00:40:00


Wait for Yukon.  Heard they would have the functionality there.




> > You can try   select convert(char(10),getdate(),120)

> ok, but this could be not compatible, if MS will change behavior in future
> releases of sql server

> MS should add more function to operate on data types, because now it's
wrong
> to make low level operations like char(10) substrings

> thanks Jaana

> > Adams

 
 
 

I need date without Time

Post by Rogéri » Wed, 25 Jun 2003 01:42:37


Adam,

The statement is...

select convert( varchar(10), current_timestamp, 120)

FORMATDATE is not a valid sql server function.

Hope this help,

Rogrio



Quote:> how to get only DATE without Time?

> i use query   select mydate from table

> field mydate is DATETIME type and contains i.e 2002-01-01 13:45:34

> i need to get only 2002-01-01 - what i have to do?

> function DATEPART only gets the one part, i need to get YEARTODAY.
> function CONVERT only uses predefined styles, why??? why i can't use like
> this  select FORMATDATE('yyyy-mm-dd', mydate) from ....   ???

> --
> Adams

 
 
 

1. Need just a date without time

Hello,

I have a Date Dimension in a data warehouse with a field called Date.  Date
is set in SQL to be a SmallDateTime type of field.  Whenever I insert a date
into this field, it always adds a default time of 00:00.00.  Is there a way
to just have a date without the time in there also?

Regards,

Randy.

2. for loop in SQL stored procedure

3. Date column without the Time information in SQL 7

4. developer account

5. Dates without times and select

6. Locking

7. Comparing two dates without time

8. Importing fields > 255 chars

9. Easier way to get Date without Time?

10. Getting Date without Time

11. how to get date without time

12. Saving default date without time (or other method)

13. Date without time