Function second2time(second As Long) As Date
Const secondInNormalYear As Long = 31536000
Const secondInLeapYear As Long = 31622400
Const secondInDay As Long = 86400
Const secondInHour As Long = 3600
Const secondInMinute As Long = 60
Dim aDayInMonth As Variant
Dim aDayInMonthNormal As Variant
aDayInMonthNormal = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
Dim aDayInMonthLeap As Variant
aDayInMonthLeap = Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
Dim bLeapYear As Boolean
Dim iThisYearSecond As Long
Dim iYear As Integer
Dim iMonth As Integer
Dim iDate As Integer
Dim iHour As Integer
Dim iMinute As Integer
Dim iSecond As Integer
Dim iNoOfDay As Integer
Dim iSecLeft As Long
iYear = 1970
Do While second > 0
' Check whether this year is leap year
If ((iYear Mod 4) = 0) Or ((iYear Mod 100) = 0) Or ((iYear Mod 400) = 0) Then
iThisYearSecond = secondInLeapYear
aDayInMonth = aDayInMonthLeap
bLeapYear = True
Else
iThisYearSecond = secondInNormalYear
aDayInMonth = aDayInMonthNormal
bLeapYear = False
End If
' Check if the second is in this year
If second > iThisYearSecond Then
' If not go to next year
second = second - iThisYearSecond
iYear = iYear + 1
Else
' If it is this year
iSecLeft = second Mod secondInDay
iNoOfDay = (second - iSecLeft) / secondInDay
second = iSecLeft
iMonth = 1
' Find Month and Date
Do While iNoOfDay > 0
' Check if the second is in this month
If iNoOfDay > aDayInMonth(iMonth) Then
iNoOfDay = iNoOfDay - aDayInMonth(iMonth)
iMonth = iMonth + 1
Else
iDate = iNoOfDay
iNoOfDay = -1
End If
Loop
iSecLeft = second Mod secondInHour
iHour = (second - iSecLeft) / secondInHour
second = iSecLeft
iSecond = second Mod secondInMinute
iMinute = (second - iSecond) / secondInMinute
second = -1
End If
Loop
' second2time = Str(iDate) + "/" + Str(iMonth) + "/" + Str(iYear) + " " + Str(iHour) + ":" + Str(iMinite) + ":" + Str(iSecond)
second2time = DateSerial(iYear, iMonth, iDate) + TimeSerial(iHour + 7, iMinute, iSecond)
End Function
วันพฤหัสบดีที่ ๒๑ เมษายน พ.ศ. ๒๕๔๘
วันศุกร์ที่ ๒๕ มีนาคม พ.ศ. ๒๕๔๘
คุณอยากเป็นไม้บรรทัดแบบไหน
ไม้บรรทัดพลาสติกแข็ง? ยอมหักไม่ยอมงอ
ไม้บรรทัดพลาสติกอ่อน? โอนอ่อนไปตามแรง งอได้ตรงได้
ไม้บรรทัดเหล็ก? งอแล้วไม่อาจตรงได้อีก
คุณอยากไม้บรรทัดแบบไหน
ไม้บรรทัดพลาสติกอ่อน? โอนอ่อนไปตามแรง งอได้ตรงได้
ไม้บรรทัดเหล็ก? งอแล้วไม่อาจตรงได้อีก
คุณอยากไม้บรรทัดแบบไหน
วันพฤหัสบดีที่ ๒๔ มีนาคม พ.ศ. ๒๕๔๘
Creating a Sequence in PL/SQL
A sequence specifies a unique value. This one will give us the number 1 the first time we use it. Then it will give us 2 then 3 etc.. if for some reason the order gets messed up it will skip 20 numbers then give us the next number in the sequence.
CREATE SEQUENCE CustomerID_SEQ
INCREMENT BY 1
START WITH 1
MINVALUE 1
MAXVALUE 9999999999
NOCYCLE
NOORDER
CACHE 20;
from Abstractvb.com
CREATE SEQUENCE CustomerID_SEQ
INCREMENT BY 1
START WITH 1
MINVALUE 1
MAXVALUE 9999999999
NOCYCLE
NOORDER
CACHE 20;
from Abstractvb.com
Returning XML From SQL Server
This "article" is really more of a quick tip. You can easily return XML from any SQL Server Query by including the words FOR XML AUTO at the end of the query.
For example this SQL statment:
SELECT * from Customer FOR XML AUTO
Would return back XML data. It's simple!
from Abstractvb.com
For example this SQL statment:
SELECT * from Customer FOR XML AUTO
Would return back XML data. It's simple!
from Abstractvb.com
Selecting the Next available Sequence number in PL/SQL
The Dual table is a special table that exists in oracle, it keeps track of sequence information for you. You can query it to return the next number in your sequence like this:
Select CustomerID_SEQ from Dual;
from Abstractvb.com
Select CustomerID_SEQ from Dual;
from Abstractvb.com
Getting the Next ID in a SQL Server Identity
If you have a field in SQL Server that has an auto-incrementing field or an "Integer with Identity", you can retrieve the next ID in the sequence by simply calling @@IDENTITY.
For example this SQL statement:
Select @@IDENTITY
Would return back a single record that would contain the next number in the sequence.
from Abstractvb.com
For example this SQL statement:
Select @@IDENTITY
Would return back a single record that would contain the next number in the sequence.
from Abstractvb.com
สมัครสมาชิก:
บทความ (Atom)