# Function to differentiate between date pattern and specific string format

I'd like to write a function that behaves one way when the argument is a Mathematica date, such as {2013,12,15}, or with added hours, minutes and seconds if necessary. And the function needs to do something different with strings that will look like

2013 Month 02

I see that I can specify List, as in f[x_List] and f[x_String] that will do what I want as long as I don't mess up the arguments. Is there way to be more specific about the patterns that are allowed?

• You can be as specific as you want tutorial/Putting constraints on patterns Anything in particular? – ssch Oct 29 '13 at 1:56
• so you only want to enter dates as lists or do you want to enter them as strings as well and differentiate between non-date strings? – Mike Honeychurch Oct 29 '13 at 2:04
• – RunnyKine Oct 29 '13 at 6:36
• I'll just use the standard mma format since I'm reading the dates in from a file. – Mitchell Kaplan Oct 29 '13 at 19:12
• @MitchellKaplan Is it your earlier account: Mitchell Kaplan? If yes, the both should be merged. – Artes Oct 31 '13 at 16:10

There is a DateQ in the Calendar package. You can test the head of DateList["string"] to make your own dateStringQ. So f[x_?DateQ] and f[x_?dateStringQ] will do.