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
How to create a login account in ms sql server to access the database engine using "create login" statements?
What does select 1 mean?
Equi join and non equi join is possible with sql server?
Can we call future method from trigger?
What is inner join? Explain with an example?
What command do we use to rename a database?
Please explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?
What are the types of processing and explain each? : sql server analysis services, ssas
What is implicit mode in sql server?
What are the 3 types of schema?
What is the difference between a unique key and primary key?
What is multilevel indexing?
Will the writetext statement activate a trigger?
Differentiate between truncate vs delete in mssql?
What is difference between rollback immediate and with no_wait during alter database?