sql server has its default date format in da form "yy-mm-dd"
its possible to convert da current date format of sql
server to desired format. Now my question is dat how to get
da previous and comin days date in my desired format??

Answer Posted / ritesh parkhi

Yes you can convert it through using
"select
convert(varchar(20),strDate,[1,2,3,4,5,6,101,102,103,104,105,106])"

diffrent diffrent code is present here you can try to use
all like
"select convert(varchar(20),strDate,101)"
where strDate is your date like "12/05/2008" or date from
database.Try it it will solve your problem.

Now second problem to get privious and cming date
"select dateadd(dd,2,strDate)"
i used here dateadd function where dd is used for Day.you
can use MM for month and YYYY fro year also.After that I
gave 2,it is the number to increment in days ,month and
year.and in last i gave strDate

Now i want to get date before 2 days so i will right
"select dateadd(dd,-2,strdate)"

Hopw you will get your answers

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

567


What is service broker?

581


What is the contrast amongst drop and truncate?

552


What are orphan records?

545


Can we update data in a view?

599






How to link tables in sql server?

473


What are the differences between char and nchar in ms sql server?

537


List out what other servers you can use with ssrs?

89


How to create a user name in a database?

584


How to stop log file growing too big?

571


Does a server store data?

500


what is an extended stored procedure? Can you instantiate a com object by using t-sql? : Sql server database administration

582


What are Row versions of DataRow?

604


What is resource governor in sql server?

544


Can you type more than one query in the query editor screen at the same time?

570