0
Explorer
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/td-p/1007708
Sep 17, 2006
Sep 17, 2006
Copy link to clipboard
Copied
I'm using the following to try and establish the number of
days difference between dates from two different record sets. The
result using test data should be 15, but I get 0. No code error
message, but no accurate result either. I've checked the two date
values involved, and they're returning the proper data in the
proper format...just can't get the DateDiff function to work in the
session variable...any help greatly apprciated.
Code:
<%Session("Lead")= DateDiff(,
[rsSurvey.Fields.Item("tblShipDat").Value],
[rsOrder.Fields.Item("tblValDat").Value])%>
Code:
<%Session("Lead")= DateDiff(
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Explorer
,
Sep 19, 2006
Sep 19, 2006
Thanks very much for all the assistance...it was indeed the
brackets around the table column names that crossed me up. Corrrect
solution:
<%
Session("Lead") = DateDiff("d", rsSurvey.Fields.Item("tblShipDat").Value,
rsOrder.Fields.Item("tblValDat").Value)
%>
All the input is greatly appreciated. Really helps the non-professional coder make progress....
Regards,
Chris Robinson
<%
Session("Lead") = DateDiff("d", rsSurvey.Fields.Item("tblShipDat").Value,
rsOrder.Fields.Item("tblValDat").Value)
%>
All the input is greatly appreciated. Really helps the non-professional coder make progress....
Regards,
Chris Robinson
LEGEND
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007709#M110209
Sep 17, 2006
Sep 17, 2006
Copy link to clipboard
Copied
On 17 Sep 2006 in macromedia.dreamweaver.appdev, stratcat900
wrote:
> I'm using the following to try and establish the number of days
> difference between dates from two different record sets. The result
> using test data should be 15, but I get 0. No code error message,
> but no accurate result either. I've checked the two date values
> involved, and they're returning the proper data in the proper
> format...just can't get the DateDiff function to work in the session
> variable...any help greatly apprciated.
>
> Code:
>
> <%Session("Lead")= DateDiff(,
> [rsSurvey.Fields.Item("tblShipDat").Value],
> [rsOrder.Fields.Item("tblValDat").Value])%>
<%Session("Lead")= DateDiff(,
The interval needs to be a string:
<%Session("Lead")= DateDiff("d",
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
> I'm using the following to try and establish the number of days
> difference between dates from two different record sets. The result
> using test data should be 15, but I get 0. No code error message,
> but no accurate result either. I've checked the two date values
> involved, and they're returning the proper data in the proper
> format...just can't get the DateDiff function to work in the session
> variable...any help greatly apprciated.
>
> Code:
>
> <%Session("Lead")= DateDiff(
> [rsSurvey.Fields.Item("tblShipDat").Value],
> [rsOrder.Fields.Item("tblValDat").Value])%>
<%Session("Lead")= DateDiff(
The interval needs to be a string:
<%Session("Lead")= DateDiff("d",
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
stratcat900
AUTHOR
Explorer
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007710#M110210
Sep 18, 2006
Sep 18, 2006
Copy link to clipboard
Copied
Thanks for the reply, Joe.
Sorry, I started out with the interval as a string, but got the following error message when the page is served:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/samples/admin/survey_detail.asp, line 224
rsLeadTime.Source = "SELECT DateDiff("d", [tblShipDat], [tblShipActualDat]) AS LeadTime FROM dbo.SampleCRM WHERE tblSampleID = " + Replace(rsLeadTime__MMColParam, "'", "''") + ""
--------------------------------------^
pointing at the the interval in quotations...that's why I tried the bracket.
Any additional suggestions for a resolution greatly appreciated.
Regards,
Chris Robinson
Sorry, I started out with the interval as a string, but got the following error message when the page is served:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/samples/admin/survey_detail.asp, line 224
rsLeadTime.Source = "SELECT DateDiff("d", [tblShipDat], [tblShipActualDat]) AS LeadTime FROM dbo.SampleCRM WHERE tblSampleID = " + Replace(rsLeadTime__MMColParam, "'", "''") + ""
--------------------------------------^
pointing at the the interval in quotations...that's why I tried the bracket.
Any additional suggestions for a resolution greatly appreciated.
Regards,
Chris Robinson
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
stratcat900
AUTHOR
Explorer
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007712#M110212
Sep 18, 2006
Sep 18, 2006
Copy link to clipboard
Copied
Sorry Joe..
My previous reply gave you the result from altering the code as you suggested, but as part of a recordset query as opposed to the session variable SQL...
Modified the SQL for the session variable as you suggested, and again, no server error, but the result is "0" when it should be "15". Any suggestions greatly apprciated.
<%Session("Lead")= DateDiff("d", [rsSurvey.Fields.Item("tblShipDat").Value], [rsOrder.Fields.Item("tblValDat").Value])%>
My previous reply gave you the result from altering the code as you suggested, but as part of a recordset query as opposed to the session variable SQL...
Modified the SQL for the session variable as you suggested, and again, no server error, but the result is "0" when it should be "15". Any suggestions greatly apprciated.
<%Session("Lead")= DateDiff("d", [rsSurvey.Fields.Item("tblShipDat").Value], [rsOrder.Fields.Item("tblValDat").Value])%>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007713#M110213
Sep 18, 2006
Sep 18, 2006
Copy link to clipboard
Copied
You're showing two different things. One is VBScript. If
you're using
VBScript, it should look like this:
<%
Session("Lead") = DateDiff("d", rsSurvey.Fields.Item("tblShipDat").Value,
rsOrder.Fields.Item("tblValDat").Value)
%>
The other you showed was T-SQL. If you're using T-SQL, it should look like
this (without the line wrap):
rsLeadTime.Source = "SELECT DATEDIFF(DAY, [tblShipDat], [tblShipActualDat])
AS LeadTime FROM dbo.SampleCRM WHERE tblSampleID = " +
Replace(rsLeadTime__MMColParam, "'", "''") + ""
You can use D in place of DAY, but no brackets, quotes, or anything else
around it. That's a keyword, not an object name or identifier.
"stratcat900" <webforumsuser@macromedia.com> wrote in message
news:eem5e9$qm$1@forums.macromedia.com...
> Sorry Joe..
>
> My previous reply gave you the result from altering the code as you
> suggested,
> but as part of a recordset query as opposed to the session variable SQL...
>
> Modified the SQL for the session variable as you suggested, and again, no
> server error, but the result is "0" when it should be "15". Any
> suggestions
> greatly apprciated.
>
> <%Session("Lead")= DateDiff("d",
> [rsSurvey.Fields.Item("tblShipDat").Value],
> [rsOrder.Fields.Item("tblValDat").Value])%>
>
VBScript, it should look like this:
<%
Session("Lead") = DateDiff("d", rsSurvey.Fields.Item("tblShipDat").Value,
rsOrder.Fields.Item("tblValDat").Value)
%>
The other you showed was T-SQL. If you're using T-SQL, it should look like
this (without the line wrap):
rsLeadTime.Source = "SELECT DATEDIFF(DAY, [tblShipDat], [tblShipActualDat])
AS LeadTime FROM dbo.SampleCRM WHERE tblSampleID = " +
Replace(rsLeadTime__MMColParam, "'", "''") + ""
You can use D in place of DAY, but no brackets, quotes, or anything else
around it. That's a keyword, not an object name or identifier.
"stratcat900" <webforumsuser@macromedia.com> wrote in message
news:eem5e9$qm$1@forums.macromedia.com...
> Sorry Joe..
>
> My previous reply gave you the result from altering the code as you
> suggested,
> but as part of a recordset query as opposed to the session variable SQL...
>
> Modified the SQL for the session variable as you suggested, and again, no
> server error, but the result is "0" when it should be "15". Any
> suggestions
> greatly apprciated.
>
> <%Session("Lead")= DateDiff("d",
> [rsSurvey.Fields.Item("tblShipDat").Value],
> [rsOrder.Fields.Item("tblValDat").Value])%>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007715#M110215
Sep 19, 2006
Sep 19, 2006
Copy link to clipboard
Copied
Thanks very much for all the assistance...it was indeed the
brackets around the table column names that crossed me up. Corrrect
solution:
<%
Session("Lead") = DateDiff("d", rsSurvey.Fields.Item("tblShipDat").Value,
rsOrder.Fields.Item("tblValDat").Value)
%>
All the input is greatly appreciated. Really helps the non-professional coder make progress....
Regards,
Chris Robinson
<%
Session("Lead") = DateDiff("d", rsSurvey.Fields.Item("tblShipDat").Value,
rsOrder.Fields.Item("tblValDat").Value)
%>
All the input is greatly appreciated. Really helps the non-professional coder make progress....
Regards,
Chris Robinson
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007711#M110211
Sep 18, 2006
Sep 18, 2006
Copy link to clipboard
Copied
Use single quotes here instead:
DateDiff("d"
Like this:
DateDiff('d'
HTH
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
DateDiff("d"
Like this:
DateDiff('d'
HTH
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/calculate-date-difference-in-session-variable/m-p/1007714#M110214
Sep 18, 2006
Sep 18, 2006
Copy link to clipboard
Copied
Use single quotes here instead:
DateDiff("d"
Like this:
DateDiff('d'
HTH
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
DateDiff("d"
Like this:
DateDiff('d'
HTH
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

