Avatar billede jensen363 Forsker
21. februar 2007 - 14:19 Der er 16 kommentarer og
1 løsning

Deadline = Registreringsdato + 4 hverdage

Dette en med garanti omtalt tidligere i Acces-kategorien, men jeg kan ikke umiddelbart finde nogen god henvisning.

På baggrund af en given brugers indtastning af nogle data, skal denne have oplyst ny deadline for opfølgning på sagen, som er :

4 hverdage efter 1. registreringsdato

Nogen ideer / løsningsforslag
Avatar billede terry Ekspert
21. februar 2007 - 14:29 #1
You could just add 4 days to the original and then keep looping until you get 4
http://support.microsoft.com/kb/210562
Avatar billede terry Ekspert
21. februar 2007 - 14:30 #2
Avatar billede terry Ekspert
21. februar 2007 - 14:31 #3
that last link was more to SQL Server
Avatar billede jensen363 Forsker
21. februar 2007 - 15:29 #4
I´m sorry, but I can´t see how this would work ... hint ?
Avatar billede terry Ekspert
21. februar 2007 - 15:41 #5
The function http://support.microsoft.com/kb/210562
is called with two dates and it returns the number of working days between the two.

So if you call it with the registreringsdato and dateadd 4 days to that it will return 4 or less

If it returns less then you add another day and call it again until it returns 4.
So now you have the Registreringsdato + 4 hverdage, dont you?
Avatar billede terry Ekspert
21. februar 2007 - 15:42 #6
but NOTE:
' Note that this function does not account for holidays
Avatar billede jensen363 Forsker
21. februar 2007 - 15:45 #7
Yes, I can see that, but

  Work_Days(#21-02-2007#;#25-02-2007#)

returns 5 days, and not 3 as I have expected ( not counting sat and sun )
Avatar billede jensen363 Forsker
21. februar 2007 - 15:54 #8
I had expected that this :

If Format(DateCnt, "ddd") <> "Sun" And _
        Format(DateCnt, "ddd") <> "Sat" Then
        EndDays = EndDays + 1
      End If

would have taken care of it, but it doesn´t seem to work
Avatar billede terry Ekspert
21. februar 2007 - 15:56 #9
I'll have a play with it to see whats happening.
Avatar billede terry Ekspert
21. februar 2007 - 15:56 #10
Work_Days(#21-02-2007#;#25-02-2007#)
returns 3 here
Avatar billede terry Ekspert
21. februar 2007 - 15:58 #11
Try calling it with
Work_Days(#2007-02-21#,#2007-02-25#)
Avatar billede terry Ekspert
21. februar 2007 - 16:04 #12
And youcan use this to add your days

Function Add4WorkingDays(inDate As Date) As Date
Dim outDate As Date
Dim i As Integer

    outDate = DateAdd("d", 4, inDate)
    i = Work_Days(inDate, outDate)
   
    Do Until i = 4
        outDate = DateAdd("d", 1, outDate)
        i = Work_Days(inDate, outDate)
   
    Loop
   
End Function
Avatar billede jensen363 Forsker
21. februar 2007 - 18:32 #13
I´m sorry, I simply can´t make it work ... the last function you made, creates a Error 6 overflow.

There must be somethint wrong with my  installation
Avatar billede terry Ekspert
21. februar 2007 - 18:57 #14
if you have danish regional settings then you will need to change , ; in functions.
Avatar billede jensen363 Forsker
21. februar 2007 - 19:26 #15
This solved the problem ... my mistake

Format(DateCnt, "ddd") <> "sø" And _
Format(DateCnt, "ddd") <> "lø" Then
Avatar billede terry Ekspert
21. februar 2007 - 20:01 #16
thanks, great to see it works, but it will very likley give problems if different regional settings are used. Maybe it can be modified to take the day number instead
Avatar billede kjulius Novice
22. februar 2007 - 02:40 #17
You can always use the Weekday function instead - that's what I would do...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester