Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split then combine two datetime fields

Status
Not open for further replies.

roody91

Technical User
Jan 16, 2002
21
0
0
US
Hello,

I do not know much about VBscript but i need to use it to manipulate some data imported to SQL Server from an Excel spreadsheet through DTS.

I have two datetime columns in a spreadsheet one has the valid date and the other has the valid time (I know this is dumb but it is how info is dumped from a legacy system)

What I need to do is take the valid date and time from there respective columns and combine them as one datetime value.

I tried several ways in but the date/functions in VBscript are a mystery to me.

Any guidance is appreciated.

Thanks,

FB
 
DateAdd Function
Returns a date to which a specified time interval has been added.

DateAdd(interval, number, date)

Arguments
interval

Required. String expression that is the interval you want to add. See Settings section for values.

number

Required. Numeric expression that is the number of interval you want to add. The numeric expression can either be positive, for dates in the future, or negative, for dates in the past.

date

Required. Variant or literal representing the date to which interval is added.

Settings
The interval argument can have the following values:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
n Minute
s Second


Remarks
You can use the DateAdd function to add or subtract a specified time interval from a date. For example, you can use DateAdd to calculate a date 30 days from today or a time 45 minutes from now. To add days to date, you can use Day of Year ("y"), Day ("d"), or Weekday ("w").

The DateAdd function won't return an invalid date. The following example adds one month to January 31:

NewDate = DateAdd("m", 1, "31-Jan-95")
In this case, DateAdd returns 28-Feb-95, not 31-Feb-95. If date is 31-Jan-96, it returns 29-Feb-96 because 1996 is a leap year.

If the calculated date would precede the year 100, an error occurs.

If number isn't a Long value, it is rounded to the nearest whole number before being evaluated.
"did you just say Minkey?, yes that's what I said."

MrGreed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top