excel 2010 get date in requested format

jassie

Rules Violation
Joined
Feb 4, 2012
Messages
30
In excel 2010, I am placing the following syntax in each row of the excel spreadsheet.
= "Update trans set c_date = 'DATEVALUE("&P1&")' where trans_ID = '"&D1&"'"
I want to obtain the trans_id and c_date values from each applicable column. I am obtaining the
trans_id value with no problem. However I am having a problem obtaining the C_date value in the
format I need it to be. I would like the date to look like the following:
2013-01-29 17:04:00.207. This format is yyyy-mm-dd hh:mm:ss:000. The date can be in a short date format.
I originally obtained the value in the C_date column from a sql server 2008 database.
Thus can you tell me what I need to do obtain the C_date value in the format I need?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,367
Office Version
  1. 365
Platform
  1. Windows
You could try using TEXT.

TEXT(P1, "yyyy-mm-dd hh:mm:ss:000")
 
Upvote 0

jassie

Rules Violation
Joined
Feb 4, 2012
Messages
30
You could try using TEXT.

TEXT(P1, "yyyy-mm-dd hh:mm:ss:000")

I am getting a synxtx error with the following line:
= "Update trans set complete_date = 'TEXT("&P1&,, "yyyy-mm-dd hh:mm:ss:000"")' where trans_ID = '"&D1&"'"

Can you tell me what is wrrong? I am new to excel and I do not know how to setup marcros like this.
 
Upvote 0

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,367
Office Version
  1. 365
Platform
  1. Windows
Replace P1 in your original formula with what I posted.

Oh, and lose the 000.

= "Update trans set c_date = 'DATEVALUE("& TEXT(P1, "yyyy-mm-dd hh:mm:ss") &")' where trans_ID = '"&D1&"'"
 
Upvote 0

Forum statistics

Threads
1,196,027
Messages
6,012,953
Members
441,740
Latest member
abaz21

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top