Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-01-16 : 05:36:09
|
| How can I return the date field 'ModifiedOn' as a string in the format dd/mm/yyyy for the script:use Debtselect DebtID, (select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), ModifiedOnfrom DebtAudit awhere ModifiedOn >= '01/13/2009' ANDModifiedOn < '01/14/2009'please? |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-16 : 05:37:18
|
| use Debtselect DebtID, (select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), ModifiedOnfrom DebtAudit awhere convert(varchar(11),ModifiedOn,101) >= '01/13/2009' ANDconvert(varchar(11),ModifiedOn,101)< '01/14/2009'Jai Krishna |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-16 : 05:39:00
|
| try thisselect DebtID, (select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), ModifiedOnfrom DebtAudit awhere dateadd(d,0,datediff(d,0,ModifiedOn)) > dateadd(d,0,datediff(d,0,@date1)) AND dateadd(d,0,datediff(d,0,ModifiedOn)) < dateadd(d,0,datediff(d,0,@date2)) |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-01-16 : 05:48:40
|
| These solutions are returning the dates as 2009-01-13 09:03:15.610Where as I need to return the dates like 13/01/2009.How can I achieve this please? |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-16 : 05:51:41
|
| use Debtselect DebtID,(select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), convert(varchar(11),ModifiedOn,103) as ModifiedOn from DebtAudit awhere convert(varchar(11),ModifiedOn,101) >= '01/13/2009' ANDconvert(varchar(11),ModifiedOn,101)< '01/14/2009' |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-16 : 05:53:49
|
| use this,select DebtID, (select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), ModifiedOnfrom DebtAudit awhere convert(varchar(32),ModifiedOn,103) >= '01/13/2009' ANDconvert(varchar(32),ModifiedOn,103)< '01/14/2009' |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-16 : 05:55:07
|
| select DebtID, (select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), ModifiedOnfrom DebtAudit awhere convert(varchar(11),ModifiedOn,103) > '13/01/2009'AND convert(varchar(11),ModifiedOn,103) < '14/01/2009' |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-16 : 05:56:01
|
quote: Originally posted by OldMySQLUser How can I return the date field 'ModifiedOn' as a string in the format dd/mm/yyyy for the script:use Debtselect DebtID, (select FullName from dbo.Users where UserID = a.OldUserID) OldUserID,(select FullName from dbo.Users where UserID = a.NewUserID) NewUserID,(select FullName from dbo.Users where UserID = a.ModifiedBy), ModifiedOnfrom DebtAudit awhere ModifiedOn >= '01/13/2009' ANDModifiedOn < '01/14/2009'please?
select convert(varchar(11),modifiedon,103) from urtableJai Krishna |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-16 : 05:57:08
|
| U are checking in where condition with another dateformat,please check it once |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-16 : 06:00:16
|
| use these links for formatting the date values check these links for date formatswww.sql-server-helper.com/tips/date-formats.aspxhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-01-16 : 07:20:07
|
| If you want to show formatted dates in front end application, do the formation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|