[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MS ACCESS datetime text field used in WeekDayName function

Posted on 2013-11-15
8
Medium Priority
?
677 Views
Last Modified: 2013-12-23
Hi, I'm wondering how I might go about using a field stored as text in the WeekDayName function.

CUSTOM_FIELD is a text field of date time ex: 201311150938

I'm thinking something like this?
WeekdayName(Weekday( Format(Mid([CUSTOM_FIELD],5,2) & "/" & Mid([CUSTOM_FIELD],7,2) & "/" & Left([CUSTOM_FIELD],4),"mm/dd/yyyy"))) AS BUCKET_DAY_NAME

but this gives me a data type mismatch
0
Comment
Question by:ghettocounselor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:AccessGuy1763
ID: 39651859
WeekdayName() needs to be passed a number between 1 and 7 (a numerical representation of the day of the week).  Most commonly, you would call just Weekday() against a Date and wrap WeekdayName() around that.

You may or may not need to do a CDate() on the Date you are constructing before passing it to Weekday()
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39651879
that should work, check for null values in the field

place Is Not Null in the criteria row of the field [CUSTOM_FIELD]

[CUSTOM_FIELD]

Is Not Null
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 39653130
To include the records with Null for [CUSTOM_FIELD] you can use:

IIf(IsDate(Format(Left([CUSTOM_FIELD], 8), "@@@@\/@@\/@@")), WeekdayName(Weekday(Format(Left([CUSTOM_FIELD] & "20000101", 8), "@@@@\/@@\/@@"), 2)), Null) As BUCKET_DAY_NAME

/gustav
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:ghettocounselor
ID: 39664271
this:
IIf(IsDate(Format(Left([CUSTOM_FIELD], 8), "@@@@\/@@\/@@")), WeekdayName(Weekday(Format(Left([CUSTOM_FIELD] & "20000101", 8), "@@@@\/@@\/@@"), 2)), Null) As BUCKET_DAY_NAME_TWO

Is working out the day but it is one day off, as in Tuesday shows as Monday, Wednesday as Tuesday.
Weekday-nov2013.png
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 39665078
WeekdayName also has a localization parameter:

IIf(IsDate(Format(Left([CUSTOM_FIELD], 8), "@@@@\/@@\/@@")), WeekdayName(Weekday(Format(Left([CUSTOM_FIELD] & "20000101", 8), "@@@@\/@@\/@@"), 2), ,2), Null) As BUCKET_DAY_NAME

/gustav
0
 

Author Comment

by:ghettocounselor
ID: 39708666
This item is still giving me 1 day off, as in it is figuring that 12 / 09 (201312092304) which was a Monday is Sunday. See image from previous post.

IIf(IsDate(Format(Left([CUSTOM_FIELD], 8), "@@@@\/@@\/@@")), WeekdayName(Weekday(Format(Left([CUSTOM_FIELD] & "20000101", 8), "@@@@\/@@\/@@"), 2), ,2), Null) As BUCKET_DAY_NAME
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 1500 total points
ID: 39708766
That's weird. The inner part:

Weekday(Format(Left("201312092304" & "20000101", 8), "@@@@\/@@\/@@"), 2)

returns 1 for Monday, thus

WeekdayName(1, ,2)

returns Monday.

/gustav
0
 

Author Closing Comment

by:ghettocounselor
ID: 39736337
In the end I think the concept and approach here are sound, something is screwy in my DB with this function. I messed and messed with it and still always found it one day off, very odd.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question