I have a DTS in Microsoft SQL Server in which I am writing an ActiveX Script
Task using VB Script Language.

I need to build a string for current date and time in this format :
YYYYMMDDHHMMSS. So I wrote this code :

Dim v_CurrentDate
Dim v_DateString

v_CurrentDate = Date
DateString = DatePart ( "yyyy", v_CurrentDate ) & _
Right ( "0" & DatePart ("m", v_CurrentDate), 2 ) & _
Right ( "0" & DatePart ("d", v_CurrentDate), 2 ) & _
Right ( "0" & DatePart ("h", v_CurrentDate), 2 ) & _
Right ( "0" & DatePart ("n", v_CurrentDate), 2 ) & _
Right ( "0" & DatePart ("s", v_CurrentDate), 2 )

But the above code is only working correctly for year, month and day part
but not the hours, month and seconds. The result I am getting is :

DateString = 20040719000000

My question is why hours, month and seconds are being returned as 000000?
What mistake I am making here?


Thanks

Re: DatePart not working completely by y

y
Mon Jul 19 11:55:26 CDT 2004

"Rizwan" <hussains@pendylum.com> wrote in message news:5iSKc.5930$Vw3.541534@news20.bellglobal.com...
> I have a DTS in Microsoft SQL Server in which I am writing an ActiveX Script
> Task using VB Script Language.
>
> I need to build a string for current date and time in this format :
> YYYYMMDDHHMMSS. So I wrote this code :
>
> Dim v_CurrentDate
> Dim v_DateString
>
> v_CurrentDate = Date
> DateString = DatePart ( "yyyy", v_CurrentDate ) & _
> Right ( "0" & DatePart ("m", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("d", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("h", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("n", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("s", v_CurrentDate), 2 )
>
> But the above code is only working correctly for year, month and day part
> but not the hours, month and seconds. The result I am getting is :
>
> DateString = 20040719000000
>
date don't have time part.
change date to Now

v_CurrentDate = now
y sakuda



Re: DatePart not working completely by Rizwan

Rizwan
Mon Jul 19 12:07:21 CDT 2004

Thanks. It works like a charm.


"y sakuda" <sakudayasuichiro@hotmail.com> wrote in message
news:e9QYyEbbEHA.1000@TK2MSFTNGP12.phx.gbl...
> "Rizwan" <hussains@pendylum.com> wrote in message
news:5iSKc.5930$Vw3.541534@news20.bellglobal.com...
> > I have a DTS in Microsoft SQL Server in which I am writing an ActiveX
Script
> > Task using VB Script Language.
> >
> > I need to build a string for current date and time in this format :
> > YYYYMMDDHHMMSS. So I wrote this code :
> >
> > Dim v_CurrentDate
> > Dim v_DateString
> >
> > v_CurrentDate = Date
> > DateString = DatePart ( "yyyy", v_CurrentDate ) & _
> > Right ( "0" & DatePart ("m", v_CurrentDate), 2 )
& _
> > Right ( "0" & DatePart ("d", v_CurrentDate), 2 )
& _
> > Right ( "0" & DatePart ("h", v_CurrentDate), 2 )
& _
> > Right ( "0" & DatePart ("n", v_CurrentDate), 2 )
& _
> > Right ( "0" & DatePart ("s", v_CurrentDate), 2 )
> >
> > But the above code is only working correctly for year, month and day
part
> > but not the hours, month and seconds. The result I am getting is :
> >
> > DateString = 20040719000000
> >
> date don't have time part.
> change date to Now
>
> v_CurrentDate = now
> y sakuda
>
>



Re: DatePart not working completely by McKirahan

McKirahan
Mon Jul 19 14:33:45 CDT 2004

"Rizwan" <hussains@pendylum.com> wrote in message
news:5iSKc.5930$Vw3.541534@news20.bellglobal.com...
> I have a DTS in Microsoft SQL Server in which I am writing an ActiveX
Script
> Task using VB Script Language.
>
> I need to build a string for current date and time in this format :
> YYYYMMDDHHMMSS. So I wrote this code :
>
> Dim v_CurrentDate
> Dim v_DateString
>
> v_CurrentDate = Date
> DateString = DatePart ( "yyyy", v_CurrentDate ) & _
> Right ( "0" & DatePart ("m", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("d", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("h", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("n", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("s", v_CurrentDate), 2 )
>
> But the above code is only working correctly for year, month and day part
> but not the hours, month and seconds. The result I am getting is :
>
> DateString = 20040719000000
>
> My question is why hours, month and seconds are being returned as 000000?
> What mistake I am making here?
>
>
> Thanks

v_CurrentDate = Now()


You "Dim v_DateString" but construct "DateString"; no "v_" prefix.

Using "Option Explicit" would detect this.




Re: DatePart not working completely by Dr

Dr
Mon Jul 19 16:36:50 CDT 2004

JRS: In article <5iSKc.5930$Vw3.541534@news20.bellglobal.com>, dated
Mon, 19 Jul 2004 12:04:18, seen in news:microsoft.public.scripting.vbscr
ipt, Rizwan <hussains@pendylum.com> posted :

>I need to build a string for current date and time in this format :
>YYYYMMDDHHMMSS. So I wrote this code :
>
>Dim v_CurrentDate
>Dim v_DateString
>
>v_CurrentDate = Date
>DateString = DatePart ( "yyyy", v_CurrentDate ) & _
> Right ( "0" & DatePart ("m", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("d", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("h", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("n", v_CurrentDate), 2 ) & _
> Right ( "0" & DatePart ("s", v_CurrentDate), 2 )
>
>But the above code is only working correctly for year, month and day part
>but not the hours, month and seconds. The result I am getting is :
>
>DateString = 20040719000000
>
>My question is why hours, month and seconds are being returned as 000000?
>What mistake I am making here?

You should have used Now.

AFAICS, the only advantage of using DatePart instead of Year, etc. is
that the code lines up so neatly.

The following approach is shorter :-

GNow = Now

DateString = _
CStr( ((((Year(GNow)*100 + Month(GNow))*100 + Day(GNow))*100 _
+ Hour(GNow))*100 + Minute(GNow))*100 + Second(GNow) )

document.write DateString

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

Re: DatePart not working completely by Daniel

Daniel
Wed Jul 21 09:01:37 CDT 2004

Hello:

since you may have the solution to my problem i would like to ask you
something, is there any problem to use

<SCRIPT LANGUAGE="VBScript"> and <SCRIPT LANGUAGE="javascript"> in the smae
page?

i am having a trouble and i suspect that maybe is this.

in a page where i use both i try the following script and it gives me an
error saying Object doesn't support this property or method when i try to
call MiFuncion

<SCRIPT LANGUAGE="VBScript">

<!--

Sub MiFuncion()

Dim Inicio

DIM Dias

Inicio = #07/01/2004#

form1.startdate.value = Inicio

dias = int(form1.horas.value) / int("8")

form1.final.value = inicio + int(dias)

End Sub

-->

</SCRIPT>

i call it like this:

<input name="final" type="Text" id="final" onFocus="Mifuncion">

When i try this in a page with only this script, it works fine

when i add it to the page where it goes, where there is other javascripts
also, it tells me that error.

Thanks for your help.

Daniel

"Dr John Stockton" <spam@merlyn.demon.co.uk> wrote in message
news:QbJIKsFy7D$AFwRi@merlyn.demon.co.uk...
JRS: In article <5iSKc.5930$Vw3.541534@news20.bellglobal.com>, dated
Mon, 19 Jul 2004 12:04:18, seen in news:microsoft.public.scripting.vbscr
ipt, Rizwan <hussains@pendylum.com> posted :

>I need to build a string for current date and time in this format :
>YYYYMMDDHHMMSS. So I wrote this code :
>
>Dim v_CurrentDate
>Dim v_DateString
>
>v_CurrentDate = Date
>DateString = DatePart ( "yyyy", v_CurrentDate ) & _
> Right ( "0" & DatePart ("m", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("d", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("h", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("n", v_CurrentDate), 2 ) &
_
> Right ( "0" & DatePart ("s", v_CurrentDate), 2 )
>
>But the above code is only working correctly for year, month and day part
>but not the hours, month and seconds. The result I am getting is :
>
>DateString = 20040719000000
>
>My question is why hours, month and seconds are being returned as 000000?
>What mistake I am making here?

You should have used Now.

AFAICS, the only advantage of using DatePart instead of Year, etc. is
that the code lines up so neatly.

The following approach is shorter :-

GNow = Now

DateString = _
CStr( ((((Year(GNow)*100 + Month(GNow))*100 + Day(GNow))*100 _
+ Hour(GNow))*100 + Minute(GNow))*100 + Second(GNow) )

document.write DateString

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for
news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates,
sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items,
links.



Re: DatePart not working completely by McKirahan

McKirahan
Wed Jul 21 09:31:52 CDT 2004

"Daniel" <trabajosdemonster@hotmail.com> wrote in message
news:#B6eAtybEHA.3804@TK2MSFTNGP10.phx.gbl...
> Hello:
>
> since you may have the solution to my problem i would like to ask you
> something, is there any problem to use
>
> <SCRIPT LANGUAGE="VBScript"> and <SCRIPT LANGUAGE="javascript"> in the
smae
> page?

[snip]

You can use both in the same page but the preferred format is:

<script type="text/javascript">
</script>
<script type="text/vbscript">
</script>

not

<script language="javascript">
<!--
// -->
</script>
<script language="vbscript">
<!--
-->
</script>