Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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??

Answers were Sorted based on User's Feedback



sql server has its default date format in da form "yy-mm-dd" its possible to convert da c..

Answer / 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

sql server has its default date format in da form "yy-mm-dd" its possible to convert da c..

Answer / rohit agarwal

hello mr. ritesh u got write queary but there should be one
modification in place of strdate it will be getdate()
funtion like this:

select datedd(dd,-2,getdate())

from this queary u will get date before 2 days due to -2
ok
so swapan try this query u will get ur answer

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

IF more than one Site is accessing the same Database server and I want to move the DB with Minimum down time? How will you do

0 Answers  


How raid can influence database performance?

0 Answers  


Can I run multiple instances of sql server 2000 at the same time on one computer?

0 Answers  


How to create a simple table to test triggers in ms sql server?

0 Answers  


write the query for taking database backup in sql

10 Answers   ABC, IBM, Logica CMG, MA,


How to get a list of columns using the "sys.columns" view in ms sql server?

0 Answers  


How do you clear a log file?

0 Answers  


Why Do you want to work in this company?

4 Answers   HCL,


Their are two tables 'A' and'B'.Table 'A' contains 3 columns named 'eid','ename','dept'. Table 'B'contains 3 columns named'sid','designation','salary'. We have to retrieve the names of employees working in the same department,same designation and same salary. Its urgent can anyone help me out in this problem.

6 Answers   Tech Mahindra,


How many types of relations are there between dimension and measure group? : sql server analysis services, ssas

0 Answers  


Explain sub-query?

0 Answers  


What is the difference between grant and with grant while giving permissions to the user?

0 Answers  


Categories