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
Can you please explain the difference between primary keys and foreign keys?
How do we know if any query is retrieving a large amount of data or very little data?
Why do we use stored procedures in sql server?
can you implement data mining in SSRS?
I have all the primary data files, secondary data files as well as logs. Now, tell me can I still restore the database without having a full backup? : sql server database administration
what exactly sql injuction.how to overcome.....
how you can move data or databases between servers and databases in sql server? : Sql server administration
how would you write a sql query to compute a frequency table of a certain attribute involving two joins? What changes would you need to make if you want to order by or group by some attribute? What would you do to account for nulls?
You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?
How to list all login names on the ms sql server?
What is a partition key?
How to verify the port number of the sql server?
How to find which stored procedure is currently running in sql server?
Can primary key be null?
Explain the different types of joins?