ahmedjamalaboelez
Ahmed J. Aboelez
- Local time
- Today, 01:01
- Joined
- Feb 25, 2015
- Messages
- 79
Good day my friends
I have this table in my financial periods details
YearID MonthID MonthStart MonthEnd
2022 01 01/01/2022 31/01/2022
2022 02 01/02/2022 28/02/2022
if i have the first date of the year ( 01/01/2022)
how could i populate 12 Records includes 12 months information same up illustrated data?
I tried this Code its work fine in access ! but not Work with Sql Server !! I think Because of how i calculate start and end date !!!
Thanks,
A.J
I have this table in my financial periods details
YearID MonthID MonthStart MonthEnd
2022 01 01/01/2022 31/01/2022
2022 02 01/02/2022 28/02/2022
if i have the first date of the year ( 01/01/2022)
how could i populate 12 Records includes 12 months information same up illustrated data?
I tried this Code its work fine in access ! but not Work with Sql Server !! I think Because of how i calculate start and end date !!!
Code:
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM fmonth_lines")
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst 'Unnecessary in this case, but still a good habit
Do Until rs.EOF = True
Dim firstdate As String
firstdate = "01" & "/" & Format(rs!fmonth_id, "00") & "/" & rs!fmonth_fyearid
rs.Edit
rs!fmonth_starts = DateSerial(Year(firstdate), month(firstdate), 1)
rs!fmonth_ends = DateSerial(Year(firstdate), month(firstdate) + 1, 0)
rs.Update
rs.MoveNext
Loop
Else
End If
rs.Close
Set rs = Nothing
A.J