473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DateTime format

164 100+
Hi in my table I have a field for storing date and datetime

i want to get date from that table using select query...

for eg select dt from tname....

Here i want to display only the date not with time.

And also time alone excluding with date....

Thanx
Dec 15 '07 #1
4 2082
VijaySofist
107 100+
Hi ArunBala!

Convert function can be used for separating date and time from the datetime field. And for your reference use the link given below

DateTime Format Link
------------------------------------
http://sqljunkies.com/HowTo/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk


Here I have used table name satuserpost, fieldname Ndate

Query for selecting the date only from a datetime field
--------------------------------------------------------------------
select convert(varchar(10),Ndate,105)'My Date' from satuserpost

Query for selecting Time from a datetime field
-----------------------------------------------------------------------
select convert(varchar(10),Ndate,108)'My Time' from satuserpost


All the Best


With Regards
Vijay. R
Dec 15 '07 #2
arunbalait
164 100+
Hi
Thanx for your reply

I have problem with it..
That is
select convert(varchar(10),Ndate,105)'My Date' from satuserpost where ndate='2007-12-15'

The above query returns no results....

WIthout where condition it is working. I want to select particular date or time..

How to do so?



Hi ArunBala!

Convert function can be used for separating date and time from the datetime field. And for your reference use the link given below

DateTime Format Link
------------------------------------
http://sqljunkies.com/HowTo/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk


Here I have used table name satuserpost, fieldname Ndate

Query for selecting the date only from a datetime field
--------------------------------------------------------------------
select convert(varchar(10),Ndate,105)'My Date' from satuserpost

Query for selecting Time from a datetime field
-----------------------------------------------------------------------
select convert(varchar(10),Ndate,108)'My Time' from satuserpost


All the Best


With Regards
Vijay. R
Dec 15 '07 #3
Jim Doherty
897 Expert 512MB
Hi
Thanx for your reply

I have problem with it..
That is
select convert(varchar(10),Ndate,105)'My Date' from satuserpost where ndate='2007-12-15'

The above query returns no results....

WIthout where condition it is working. I want to select particular date or time..

How to do so?
your posted syntax is verifably correct and should be returning an italian (105) converted date type value as varchar
What does your data look like in SQL server when you return * from ndate do you have your field set as datetime datatype

select convert(varchar(10),Ndate,105) [My Date] from satuserpost where Ndate='2007-12-15'

Jim :)
Dec 17 '07 #4
arunbalait
164 100+
your posted syntax is verifably correct and should be returning an italian (105) converted date type value as varchar
What does your data look like in SQL server when you return * from ndate do you have your field set as datetime datatype

select convert(varchar(10),Ndate,105) [My Date] from satuserpost where Ndate='2007-12-15'

Jim :)
Hi...

Thanks

Ya my data format is datetime datatype...

select convert(varchar(10),Ndate,105) [My Date] from satuserpost where Ndate='2007-12-15'

the above query gives 0 rows affected...

Help me plz... I want to take report on particular date... If i have given where condition it doesnt affect any values...


I want the result for

select username from mytable where dt='2007-12-18'


dt= field name in my table.. it is in datetime datatype..

thanx
Dec 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
4
by: Arpan | last post by:
A SQL Server 2005 DB table has 4 columns namely "ID" (IDENTITY int column), "FirstName" (varchar(50)), "LastName" (varchar(50)) & "DOB" (datetime). Now when I am trying to add a new row using the...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.