---
title: "varför fungerar inte detta?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/8360-varför-fungerar-inte-detta"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "brw"
published: "2001-02-28T12:00:00.000Z"
updated: "2001-02-28T12:30:00.000Z"
replies: 2
views: 163
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/8360-varför-fungerar-inte-detta"
---

# varför fungerar inte detta?

## #1 — brw, 2001-02-28T12:00Z

Nu har jag hållit på och försökt få ihop det är i 1 timme.. 
Varför fungerar inte detta? måste man göra nå special när det är datum med nå # prylar eller? :l

```
<%
If datumbeg = "j" Then

fromyear = RS2("fromyear")
frommonth = RS2("frommonth")
fromday = RS2("fromday")

toyear = RS2("toyear")
tomonth = RS2("tomonth")
today = RS2("today")

If frommonth < 10 Then
frommonth = 0 & frommonth
'frommonth = Cint(frommonth)
End If

If fromday < 10 Then
fromday = 0 & fromday
'fromday = Cint(fromday)
End If

If tomonth < 10 Then
tomonth = 0 & tomonth
'tomonth = Cint(tomonth)
End If

If today < 10 Then
today = 0&today
'today = Cint(today)
End If

datumfran = fromyear & "-" & frommonth & "-" & fromday
datumtill = toyear & "-" & tomonth & "-" & today

datum = date

response.write datum & "<br>"

response.write datumfran & "<br>" & datumtill

If datumfran = datum Then
response.write "Fungerar"
End IF

If datum >= datumfran AND datum <= datumtill Then
response.write "Fungerar"
End IF

End If
%>
```

Permalänk: https://www.webforum.nu/p/8360

## #2 — MattiasW, 2001-02-28T12:23Z

Är inte säker på att mitt tips fungerar, helt klart värt ett försök.

När du hämtar fromyear,osv variablerna från databasen skall du försäkra dig om att det blir riktiga integers.

Typ:
if IsNull(RS2("fromyear")) Then
  fromyear = 0
else
  fromyear = CInt(RS2("fromyear"))
endif

Sedan kan du göra dina tester med \< 10.

När du tilldelar din datumvariabel bör du använda funktionen CDate:
datumtill = CDate(toyear & "-" & tomonth & "-" & today)

Permalänk: https://www.webforum.nu/p/260198

## #3 — brw, 2001-02-28T12:30Z

Tackar så hjärtligt!

Fungerar utmärkt.

Permalänk: https://www.webforum.nu/p/260199

---

Tråden på webben: https://www.webforum.nu/amne/asp/8360-varför-fungerar-inte-detta
