Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
datediff
Dear Expert
I try to use DateDiff but it doesn't work, when I try to use this simple function excel say #NAME? This is what I have Function session_num(start_date As Date, today_date As Date) As Long 'Determine the # of weeks between today date and Start Date session_num = DateDiff("ww", today_date, start_date) End Function |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
datediff
try:
DATEDIF in place of: DATEDIFF -- Gary''s Student - gsnu200850 "Mijosuva" wrote: Dear Expert I try to use DateDiff but it doesn't work, when I try to use this simple function excel say #NAME? This is what I have Function session_num(start_date As Date, today_date As Date) As Long 'Determine the # of weeks between today date and Start Date session_num = DateDiff("ww", today_date, start_date) End Function |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
datediff
DATEDIF() is a worksheet function whereas;
DATEDIFF() function is a VBScript function which should work. The syntax is DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]]). Try the below in your immediate window which should return 2 weeks. DateDiff("w", Date()-14, Date()) If this post helps click Yes --------------- Jacob Skaria "Mijosuva" wrote: Dear Expert I try to use DateDiff but it doesn't work, when I try to use this simple function excel say #NAME? This is what I have Function session_num(start_date As Date, today_date As Date) As Long 'Determine the # of weeks between today date and Start Date session_num = DateDiff("ww", today_date, start_date) End Function |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
datediff
The VB DateDiff function requires the earlier date to be placed first and
the later date second... you have them reversed. Try this line in your function instead... session_num = DateDiff("ww", start_date, today_date) -- Rick (MVP - Excel) "Mijosuva" wrote in message ... Dear Expert I try to use DateDiff but it doesn't work, when I try to use this simple function excel say #NAME? This is what I have Function session_num(start_date As Date, today_date As Date) As Long 'Determine the # of weeks between today date and Start Date session_num = DateDiff("ww", today_date, start_date) End Function |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
datediff
Chip Pearson has some very nice notes:
http://www.cpearson.com/excel/datedif.aspx Mijosuva wrote: Dear Expert I try to use DateDiff but it doesn't work, when I try to use this simple function excel say #NAME? This is what I have Function session_num(start_date As Date, today_date As Date) As Long 'Determine the # of weeks between today date and Start Date session_num = DateDiff("ww", today_date, start_date) End Function -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
datediff
Thanks for the help, but I found the solution, Rick your right but security
option of Macros should be enable. "Mijosuva" wrote: Dear Expert I try to use DateDiff but it doesn't work, when I try to use this simple function excel say #NAME? This is what I have Function session_num(start_date As Date, today_date As Date) As Long 'Determine the # of weeks between today date and Start Date session_num = DateDiff("ww", today_date, start_date) End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
DateDiff() problem | Excel Programming | |||
datediff help | Excel Programming | |||
DateDIFF | Excel Programming | |||
Help with datediff vba | Excel Programming | |||
DateDiff in Excel | Excel Programming |